package com.zte.springboot_smbms.Proxy;

import org.apache.log4j.Logger;
//import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

//@Component
//@Aspect//表明当前类是一个切面类
public class TransactionManager {

    private static Logger log = Logger.getLogger(TransactionManager.class);


    /**
     * 开启事务
     */
//    @Before("execution(* com.zte.service.impl.*.*(..))")
    public void beginTransaction() {
        try {
            log.debug("开启事务");
            System.out.println("开启事务");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 提交事务
     */
//    @AfterReturning("execution(* com.zte.service.impl.*.*(..))")
    public void commit() {
        try {
            log.debug("提交事务");
            System.out.println("提交事务");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 回滚事务
     */
//    @AfterThrowing("execution(* com.zte.service.impl.*.*(..))")
    public void rollback() {
        try {
            log.debug("回滚事务");
            System.out.println("回滚事务");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 释放连接
     */
//    @After("execution(* com.zte.service.impl.*.*(..))")
    public void release() {
        try {
            log.debug("释放资源");
            System.out.println("释放资源");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
